package com.ts.main.admin.controller;

import com.ts.main.admin.dto.OrderDto;
import com.ts.main.admin.dto.OrderSearchPageDto;
import com.ts.main.admin.exception.R;
import com.ts.main.admin.exception.RPage;
import com.ts.main.admin.service.OrderServiceImpl;
import com.ts.main.admin.vo.OrderVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:lk
 * @Date: 2025/6/9  16:50
 */
@AllArgsConstructor
@RestController
@RequestMapping("/order")
@Tag(name = "订单管理")
public class OrderController {

    private final OrderServiceImpl orderService;


    @PostMapping("/getOrderList")
    @Operation(summary = "查询订单列表")
    public RPage<List<OrderVo>> getOrderPage(@RequestBody OrderSearchPageDto dto) {
        return orderService.getOrderPage(dto);
    }

    @GetMapping("/getOrderDetails")
    @Operation(summary = "查询订单详情")
    public R<OrderVo> getOrderDetails(@Schema(description = "订单ID") @RequestParam Integer orderId) {
        return R.ok(orderService.getOrderDetails(orderId));
    }

    @PutMapping("/updateOrder")
    @Operation(summary = "修改订单，上传发货信息")
    public R<Boolean> updateOrder(@RequestBody OrderDto dto) {
        return R.ok(orderService.updateOrder(dto));
    }

}
